package com.JobFind.DAO.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import com.JobFind.DAO.ILogDAO;
import com.JobFind.model.TbLog;

@Component
public class LogDAO implements ILogDAO {
	private SessionFactory sessionFactory;

	@Resource
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public Integer addLog(TbLog logBean) throws Exception {
		Integer result = 0;
		try {
			Session session = sessionFactory.getCurrentSession();
			result = (Integer) session.save(logBean);
		} catch (Exception e) {
			e.printStackTrace();
			result = 0;
		}
		return result;
	}

}
